﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using ASPItalia.ModelVirtualCasting.WPF.ViewModels;
using System.Runtime.InteropServices;
using Microsoft.Expression.Encoder.Live;

namespace ASPItalia.ModelVirtualCasting.WPF.Views
{
    /// <summary>
    /// Interaction logic for RecordView.xaml
    /// </summary>
    public partial class RecordView : Window
    {

        private PreviewWindow livePreviewWindow;

        public RecordView()
        {
            InitializeComponent();

            this.Loaded += new RoutedEventHandler(RecordView_Loaded);
        }

        private void RecordView_Loaded(object sender, RoutedEventArgs e)
        {
            // Create a WinForm control used as container
            this.previewWindow.Child = new System.Windows.Forms.Control();

            HandleRef handle = new HandleRef(this.previewWindow.Child, this.previewWindow.Child.Handle);
            livePreviewWindow = new PreviewWindow(handle);

            ((RecordViewModel)this.DataContext).PreviewWindow = livePreviewWindow;
        }

        private void CloseButton_Click(object sender, RoutedEventArgs e)
        {            
            this.Close();
        }
    }
}
